﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using ReportMobile.inc;

namespace ReportMobile.v2
{
    public partial class SYB_feed : System.Web.UI.Page
    {
        public string urlArea;  //URL中的区域变量
        public string areaName; //转换URL中的区域变量为中文名称
        public string rmbTotal; //区域余额合计
        public string areaIn;   //SQL查询用In字符串
        public DataTable dt2 = new DataTable();
        public DataTable dt = new DataTable();
        public DataSet ds = new DataSet();
        public Common cm = new Common();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["area"] == null)
                return;
            urlArea = Request.QueryString["area"];
            if (urlArea == "cyq"){
                areaName = "川渝区";
                areaIn = "('猪料（非放养）','猪场料（非放养）','鸡料','鱼料','其它')";
            }else{
                areaName = "非川渝";
                areaIn = "('北京','长春','昆明','西安','咸阳','武威','湖北')";
            }
            //areaName = urlArea == "cyq" ? "川渝区" : "非川渝";

            dt = cm.ExecuteProcedure("execute Feed_Detail");
            dt2 = dt.Copy();
            dt.DefaultView.RowFilter = "区域 in ('" + areaName + "')";   //SQL表达式，但不写SQL关键字
            dt = dt.DefaultView.ToTable();
            string[] xValues = { "借款合计：" + string.Format("{0:N}",dt.Rows[0]["临时借款"]), 
                                   "贷款合计：" + string.Format("{0:N}",dt.Rows[0]["贷款"])};
            double[] yValues = {Convert.ToDouble(dt.Rows[0]["临时借款"]),Convert.ToDouble(dt.Rows[0]["贷款"])};
            cyqChart.Series["Series1"].Points.DataBindXY(xValues, yValues);
            cyqChart.Width = 380;
            rmbTotal = string.Format("{0:N}",dt.Rows[0]["合计"]);
            dt2.DefaultView.RowFilter = "区域 in " + areaIn; 
            dt2.DefaultView.Sort = " 合计 desc";
            ds.Tables.Add(dt2.DefaultView.ToTable());
            rptFeedDetail.DataSource = ds;
            rptFeedDetail.DataBind();
        }
    }
}